package com.aizuda.boot.modules.common.constant.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum NegotiationStatusEnum {
    IN_NEGOTIATION("IN_NEGOTIATION", "审核中"),
    NEGOTIATION_COMPLETE("NEGOTIATION_COMPLETE", "审核完成"),
    PENDING_NEGOTIATION("PENDING_NEGOTIATION", "待发起审核"),
    NEGOTIATION_CANCELED("NEGOTIATION_CANCELED", "取消审核");

    private final String code;
    private final String msg;
    
    /**
     * 根据code获取对应的message
     * @param code 状态码
     * @return 对应的消息，如果未找到则返回原code
     */
    public static String getMsgByCode(String code) {
        if (code == null) {
            return null;
        }
        for (NegotiationStatusEnum status : values()) {
            if (status.getCode().equals(code)) {
                return status.getMsg();
            }
        }
        return code; // 如果没找到对应的枚举，返回原code
    }
    
    /**
     * 根据中文message获取对应的code
     * @param msg 中文状态
     * @return 对应的英文代码，如果未找到则返回原msg
     */
    public static String getCodeByMsg(String msg) {
        if (msg == null) {
            return null;
        }
        for (NegotiationStatusEnum status : values()) {
            if (status.getMsg().equals(msg)) {
                return status.getCode();
            }
        }
        return msg; // 如果没找到对应的枚举，返回原msg
    }
}